<!--
 * @Description: 
 * @Author: 张文韬
 * @Date: 2024-06-24 15:29:13
 * @LastEditTime: 2024-07-14 18:00:53
 * @LastEditors: 张文韬
 * @Reference: 
-->
<template>
  <section class="p-10px bg-#eee c-red border-rounded-10px">
    <div>保单号或证件号必须填一个才能查出</div>
    <div>多选请一定要选同一个保单</div>
  </section>
  <section mt-15px>
    <el-form inline>
      <el-form-item label="保单: ">
        <el-input class="mr-20px" v-model="companyInfo.title" placeholder="请选择企业名称" clearable />
      </el-form-item>
      <el-form-item label="证件号码: ">
        <el-input class="mr-20px" v-model="companyInfo.title" placeholder="请选择企业名称" clearable />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="getData">查询</el-button>
        <el-button type="primary" @click="reset">重置</el-button>
      </el-form-item>
    </el-form>
    <e-table
      :data="tableData"
      :columns="columns"
      :loading="loading"
      :border="false">
      <template #select="{ scope }">
        <el-radio :value="scope.row.id" size="large" />
      </template>
    </e-table>
  </section>
</template>

<script setup>

import { columns } from './config';
import { destination } from '@/api/insurance';

const props = defineProps({
  loading: {
    type: Boolean,
    default: false
  },
  data: {
    type: Object,
    default: () => {}
  },
})

const companyInfo = ref({})
const tableData = ref([])

const getData = async() => {
  const res = await destination({route: 'view'})
  tableData.value = res.data
}

const reset = () => {
  companyInfo.value = {}
}

const getSelectData = () => unref(companyInfo)

defineExpose({
  getSelectData
})

watch(() => props.data, (val) => {
  companyInfo.value = val
})

onMounted(async() => {
  console.log('onMounted');
  // getData()
})

</script>